<template>
  <div>
    <div v-for="(val,index) in list" :key="index">
      <input type="checkbox" :value="val" v-model="sumlist" />
      <span>{{val}}</span>
    </div>
    <p>你选中的元素，累加和的值为:{{alllist}}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      sumlist: [],
    };
  },
  computed: {
    alllist() {
      return this.sumlist.reduce((sum, val) => (sum += val), 0);
    },
  },
};
</script>

<style>
</style>